package cn.yl.caner.web;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.yl.caner.service.CheckService;

public class CheckPassword extends HttpServlet {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	//ajax检查密码是否正确
	public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String username = request.getParameter("username");
		String password =request.getParameter("password");
		CheckService checkService = new CheckService();
		boolean isPassword = false;
		//用来测试时候接受到用户名和密码
		System.out.println(username+","+password);
		if(username != null && password != null) {
			isPassword =checkService.checkPassword(password,username);
			System.out.println("检查密码返回的状态"+isPassword);
			response.getWriter().write("{\"isPassword\":"+isPassword+"}");
		}
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}
}